package com.jwgf.queueprogramflash;

import com.jwgf.smarowindingmachine_unity.logic.MachineParameterSharedPreference;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

public class JumpUserCallable implements Callable<List<Integer>> {

    @Override
    public List<Integer> call() throws Exception {
        List<Integer> allSpindles = new ArrayList<>();
        for (int i = 2; i <= Integer.valueOf(MachineParameterSharedPreference.getInstance().getValue(0x29, 01)) + 1; ++i) {
            allSpindles.add(i);
        }
        for (int spindle : allSpindles) {
            byte[] jumpUserCmd = FlashCommand.createJumpUser(spindle);
            FlashManager.getInstance().send(jumpUserCmd);
        }
        try {
            Thread.sleep(4 * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return FlashManager.getInstance().getEchoSpindles();

    }

}
